package pl.edu.pjwstk.kor.sbql4j.project2;

import pl.wcislo.sbql4j.db4o.Db4oSBQLQuery;
import com.db4o.ObjectContainer;

import org.apache.commons.collections.CollectionUtils;

import pl.edu.pjwstk.kor.database.Database;
import pl.edu.pjwstk.kor.database.Sbql4jQuery;
import pl.edu.pjwstk.kor.model.Customer;
import pl.edu.pjwstk.kor.model.Deal;
import pl.edu.pjwstk.kor.model.Employee;
import pl.edu.pjwstk.kor.model.Employee;
import pl.edu.pjwstk.kor.model.Rank;

import pl.wcislo.sbql4j.exception.*;
import pl.wcislo.sbql4j.java.model.compiletime.Signature.SCollectionType;
import pl.wcislo.sbql4j.java.model.runtime.*;
import pl.wcislo.sbql4j.java.model.runtime.factory.*;
import pl.wcislo.sbql4j.java.utils.ArrayUtils;
import pl.wcislo.sbql4j.java.utils.OperatorUtils;
import pl.wcislo.sbql4j.java.utils.Pair;
import pl.wcislo.sbql4j.lang.codegen.nostacks.*;
import pl.wcislo.sbql4j.lang.codegen.simple.*;




import pl.wcislo.sbql4j.lang.parser.expression.*;
import pl.wcislo.sbql4j.lang.parser.expression.OrderByParamExpression.SortType;
import pl.wcislo.sbql4j.lang.parser.terminals.*;
import pl.wcislo.sbql4j.lang.parser.terminals.operators.*;
import pl.wcislo.sbql4j.lang.types.*;
import pl.wcislo.sbql4j.lang.xml.*;
import pl.wcislo.sbql4j.model.*;
import pl.wcislo.sbql4j.model.collections.*;
import pl.wcislo.sbql4j.util.*;
import pl.wcislo.sbql4j.util.Utils;
import pl.wcislo.sbql4j.xml.model.*;
import pl.wcislo.sbql4j.xml.parser.store.*;

import java.util.*;
import java.util.Collection;


public class Project2Query_SbqlQuery0 {
    private com.db4o.ObjectContainer db;
    private java.lang.Integer dealCount;

    public Project2Query_SbqlQuery0(final com.db4o.ObjectContainer db,
        final int dealCount) {
        this.db = db;
        this.dealCount = dealCount;
    }

    /**
     * original query='db.((Employee as emp) where count(emp.deals) > dealCount)'
     *
     * query after optimization='db.(Employee as emp where  count(emp.getDeals()) > dealCount)'
    */
    public java.util.Collection<pl.edu.pjwstk.kor.model.Employee> executeQuery() {
        com.db4o.ObjectContainer _ident_db = db;
        java.util.Collection<pl.edu.pjwstk.kor.model.Employee> _queryResult = (java.util.Collection<pl.edu.pjwstk.kor.model.Employee>) _ident_db.query(new Project2Query_SbqlQuery0Db4o0(
                    dealCount));

        return _queryResult;
    }
}
